#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    while (n != 495)
    {
        int a = n % 10;
        int b = n / 10 % 10;
        int c = n / 100;
        // 将a,b,c 从小到大排序
        if (a > b)
            swap(a, b);
        if (c < a)
            swap(a, c);
        if (c < b)
            swap(c, b);
        int da = c * 100 + b * 10 + a;
        int xiao = ? ? n = da - xiao;
    }
    return 0;
}